/**
 * @Author 12629
 * @Description：
 */
class Food {

}
class Fruit extends Food {

}
class Apple extends Fruit {

}
class Banana extends Fruit {

}

class Plate<T> {
    private T plate ;

    public T getPlate() {
        return plate;
    }

    public void setPlate(T plate) {
        this.plate = plate;
    }
}
class Message<T> {
    private T message;

    public T getMessage() {
        return message;
    }

    public void setMessage(T message) {
        this.message = message;
    }
}


public class Test2 {

    public static void fun(Message<?> temp){
        System.out.println(temp.getMessage());
    }

    public static void funExtends(Message<? extends Fruit> temp){
        System.out.println(temp.getMessage());

        //通配符的上界来说 是不可以进行修改元素的
        /*temp.setMessage(new Banana());
        temp.setMessage(new Apple());*/

        //向上转型
        Fruit fruit = temp.getMessage();

    }

    public static void funSuper(Plate<? super Fruit> temp){
        // 此时可以修改！！添加的是Fruit 或者Fruit的子类
        temp.setPlate(new Apple());//这个是Fruit的子类   向上转型
        temp.setPlate(new Banana());//这个是Fruit的本身

        //Fruit fruit = temp.getPlate(); //不能接收，这里无法确定是哪个父类
        System.out.println(temp.getPlate());//只能直接输出
    }

    public static void main(String[] args) {
        Plate<Fruit> message1 = new Plate<>();

        Plate<Food> message2 = new Plate<>();

        funSuper(message1);
        funSuper(message2);
    }

    public static void main2(String[] args) {
        Message<Apple> message1 = new Message<>();
        message1.setMessage(new Apple());

        Message<Banana> message2 = new Message<>();
        message2.setMessage(new Banana());

        funExtends(message1);
        funExtends(message2);

    }

    public static void main1(String[] args) {
        Message<String> message = new Message<>();
        message.setMessage("你好！");
        fun(message);


        Message<Integer> message2 = new Message<>();
        message2.setMessage(199);
        fun(message2);
    }
}
